/*
 * DevicesLed.h
 *
 *      Author: Honrun
 */

#ifndef BSP_DEVICESLED_H_
#define BSP_DEVICESLED_H_


#define LED_WHITE_GPIO_Port  GPIOB
#define LED_WHITE_Pin        GPIO_PIN_6

#define LED_YELLOW_GPIO_Port GPIOA
#define LED_YELLOW_Pin       GPIO_PIN_15

#define LED_GREEN_GPIO_Port  GPIOA
#define LED_GREEN_Pin        GPIO_PIN_6





#define LED_RED    0x01
#define LED_GREEN  0x02
#define LED_BLUE   0x04
#define LED_YELLOW 0x08
#define LED_WHITE  0x10
#define LED_ALL    0xFF


typedef enum {
    LED_IDLE                    = 0,
    LED_DISABLE,                /* 关闭 */
    LED_ENABLE,                 /* 常亮 */
    LED_FLASH_SLOW,             /* 循环慢闪（0.5Hz） */
    LED_FLASH_SLOW_ENABLE_CNT,  /* 慢闪N次后LED常亮 */
    LED_FLASH_SLOW_DISABLE_CNT, /* 慢闪N次后LED关闭 */
    LED_FLASH_FAST,             /* 循环快闪（1Hz） */
    LED_FLASH_FAST_ENABLE_CNT,  /* 快闪N次后LED常亮 */
    LED_FLASH_FAST_DISABLE_CNT, /* 快闪N次后LED关闭 */
    LED_BREATHE,                /* 呼吸 */
    LED_DUTY,                   /* 固定占空比 */
} LedStateEnum;


typedef struct{
    LedStateEnum state; /* 状态 */
    int8_t flashCnt;    /* 闪烁次数 */
    int8_t duty;        /* 占空比 */

    uint16_t channel;
    uint32_t timerPeriph;
    uint32_t periph;
    uint32_t pin;
}LedType;


typedef struct{
    LedType white;
    LedType yellow;
    LedType green;
}LedInfoType;




void vLedInit(void);
void vLedOpen(uint16_t ucNumber);
void vLedClose(uint16_t ucNumber);
void vLedRevesal(uint16_t ucNumber);

void vLedSetStatus(uint16_t usChannel, LedStateEnum enumStatus, uint8_t ucFlashCnt_or_Duty);
void vLedMachine(void);

LedInfoType *ptypeLedGetInfo(void);


#define LED_OPEN()      vLedOpen(LED_ALL)
#define LED_CLOSE()     vLedClose(LED_ALL)
#define LED_REVESAL()   vLedRevesal(LED_ALL)



#endif /* BSP_DEVICESLED_H_ */
